import maya.cmds as cmds
class jointCurveBlend():
    def __init__(self):
        pass
    def CurveInfo(self,jntLable ='',curveSurface='',curveSurfaceAim='',numberGrp=8):
        curveSpace = cmds.listRelatives(curveSurface)
        curveAimSpace = cmds.listRelatives(curveSurfaceAim)
        curveMaxValue = cmds.getAttr(curveSurface+'.maxValue')

        for i in range(numberGrp):
            pciNode = cmds.createNode('pointOnCurveInfo',name = jntLable +'_Pci' + str(i))
            aimPciNode = cmds.createNode('pointOnCurveInfo',name = jntLable +'_AimPci'+  str(i))
            aimPciTransform = cmds.createNode('transform',name = jntLable +'_AimPciGrp'+  str(i))
            pciTransform = cmds.createNode('transform',name =  jntLable +'_PciGrp'+ str(i))

            jnt = cmds.joint( name =jntLable +'_Jnt'+str(i))
            cmds.select()
            cmds.addAttr(jnt ,longName = 'parameter',at = 'double')
            cmds.setAttr(jnt+'.parameter',edit=True,keyable = True)
            cmds.connectAttr(jnt+'.parameter',pciNode+'.parameter')
            cmds.connectAttr(jnt+'.parameter',aimPciNode+'.parameter')

            cmds.connectAttr(curveSpace[0]+'.worldSpace[0]',pciNode+'.inputCurve')
            cmds.connectAttr(pciNode+'.positionX',pciTransform+'.translateX')
            cmds.connectAttr(pciNode+'.positionY',pciTransform+'.translateY')
            cmds.connectAttr(pciNode+'.positionZ',pciTransform+'.translateZ') 

            cmds.connectAttr(curveAimSpace[0]+'.worldSpace[0]',aimPciNode+'.inputCurve')
            cmds.connectAttr(aimPciNode+'.positionX',aimPciTransform+'.translateX')
            cmds.connectAttr(aimPciNode+'.positionY',aimPciTransform+'.translateY')
            cmds.connectAttr(aimPciNode+'.positionZ',aimPciTransform+'.translateZ') 

            if curveMaxValue > 1 :
                cmd = ( int(curveMaxValue) * 0.1 * 10) / (numberGrp - 1 )
            elif curveMaxValue == 1:
                cmd =  1.0 / (numberGrp - 1)
            

            cmds.setAttr(jnt+'.parameter',(cmd*i)) 
            cmds.setAttr(jnt+'.parameter',(cmd*i)) 

            cmds.tangentConstraint(curveSurface,pciTransform,weight=True,aimVector=(1,0,0),upVector=(0,1,0),worldUpType='object',worldUpObject = aimPciTransform )
